<?php

echo '<form action="index.php" method="POST"><input type=submit value=Anuluj class="butt4"></form>';


$_SESSION['ed_user']=$_POST['ed_user'];
$sql="select * from users where id =".$_POST['ed_user'];
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$uzytk=$row;
}

$_SESSION['ed_uzytk_haslo']=$uzytk['haslo'];

$sql="select * from user_gab where id_user =".$_POST['ed_user'];
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$uzytk_gab[]=$row['id_gab'];
}

if (!$uzytk_gab) $uzytk_gab[0]=1;


$sql="select * from sl_gab";
$result=mysql_query($sql);
while($row = mysql_fetch_array($result))
{
$sl_gab[$row['id']]=$row['nazwa'];
}



?>
 <script>
$(document).ready(function(){
$("#fancy").validate();
$('.required').bestupper();
 });
</script>



<form class="fancy" id="fancy" method="post" action="">
 <fieldset >
   <legend>Edycja użytkownika <?php echo $uzytk['nazwa']; ?></legend>
   <ul>
   <li>
     <label for="cnaz">Nazwisko*</label>
     <input id="cnaz" name="nazwisko" size="45" class="required" value="<?php echo $uzytk['nazwisko']; ?>" />
   </li>
	<li>
     <label for="cnaz">Imię*</label>
     <input id="cnaz" name="imie" size="45" class="required" value="<?php echo $uzytk['imie']; ?>" />
   </li>
	<li>
     <label for="cnaz">Hasło*</label>
     <input type="password" id="cnaz" name="haslo" size="20" class="required" value="<?php echo $uzytk['haslo']; ?>" />
   </li>
	<li>
     <label for="ckod">Gabinety</label>
     <select class="required" name="gabinety[]" multiple="multiple" id="gabinety" size="10">
     
     <?php 
     foreach ($sl_gab as $i=>$w){
     	
     	echo '<option value="'.$i.'"';
     	
   		 if (in_array($i, $uzytk_gab)) {
    	echo " selected ";
		}
     	
     	echo '>'.$w.'</option>';
     	
     }  
     ?>
	</select>
   </li>
	<li>
     <label for="cnaz">Hasło do*</label>
     <input id="cnaz" name="haslo_do" size="12" class="datepicker" value="<?php echo $uzytk['haslo_do']; ?>" />
   </li>
	<li>
     <label for="cnaz">Aktywny*</label>
     <input type="checkbox" name="akt" <?php if($uzytk['akt']==1)  echo 'checked';  ?> />
   </li>

 <li>
     <input class="submit" name="user_ed_zap" type="submit" value="Zapisz"/>
   </li>
   </ul>
 </fieldset>
 </form>




















